import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { dbConfig } from './config/dbConfig';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import {
  ArticleModule,
  AuthModule,
  LoginModule,
  OrderModule,
  RoleModule,
  UpLoadFileModule,
  UserModule,
} from './modules/index';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: dbConfig.host,
      port: dbConfig.port,
      username: dbConfig.username,
      password: dbConfig.password,
      database: dbConfig.database,
      entities: [__dirname + '/**/*.entity{.ts,.js}'],
      synchronize: false, // 不要同步表，同步会清除原有数据
      logging: 'all',
    }),
    LoginModule,
    UserModule,
    UpLoadFileModule,
    OrderModule,
    RoleModule,
    AuthModule,
    ArticleModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
